#include <GL/glut.h>
#include <math.h>
#include "model/elements/scene/Textures.h"
#include "model/elements/scene/Objects.h"
#include "view/screens/screens.h"


using namespace std;

int screenMode=OPENING;

OpeningScreen *opening;
EditorScreen *editor;
TurnScreen *turn;
GamePlayScreen *gameplay;
EndScreen *end;


vector<AbstractScreen*> screens;

void display(void)
{
	screens[screenMode]->display();
}

void keyboard(unsigned char key,int x, int y)
{
	screens[screenMode]->keyboard(key,x,y);
}

void special(int key,int x, int y)
{
	screens[screenMode]->keyboard(key,x,y);
}

void mouse(int button, int state,int x, int y)
{
	screens[screenMode]->mouse(button,state,x,y);
}


void motion(int x, int y)
{
	screens[screenMode]->motion(x,y);
}

void passiveMotion(int x, int y)
{
	screens[screenMode]->passiveMotion(x,y);
}

//after phase1

void keyboardUp(unsigned char key,int x,int y)
{
	screens[screenMode]->keyboardUp(key,x,y);
}

void specialUp(int key,int x, int y)
{
	screens[screenMode]->specialUp(key,x,y);

}

void initialize()
{
	opening=new OpeningScreen("./maps/");
	editor=new EditorScreen();
	turn=new TurnScreen();
	gameplay=new GamePlayScreen();
	end=new EndScreen();

	screens.push_back(opening);
	screens.push_back(editor);
	screens.push_back(turn);
	screens.push_back(gameplay);
	screens.push_back(end);
}

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
	glutInitWindowPosition( 50, 50 );
	glutInitWindowSize(WIDTH,HEIGHT);
	glutCreateWindow( (char *)"CENG 477 Game Project by GULSAH&CANSIN " );

	glViewport(0,0,WIDTH,HEIGHT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0,WIDTH,0,HEIGHT,0,600);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glutDisplayFunc(display);
	glutKeyboardFunc(keyboard);
	glutMouseFunc(mouse);
	glutSpecialFunc(special);
	glutMotionFunc(motion);
	glutPassiveMotionFunc(passiveMotion);

	glutKeyboardUpFunc(keyboardUp);
	glutSpecialUpFunc(specialUp);

	initialize();
	Textures::initialize();
	Objects::initialize();

	glutMainLoop();

	return 0;
}
